﻿using System.Text;

namespace SolutionGeneratorHelper
{
    internal class ProjectRef : CommonNode, IProjectRef
    {
        private const string strSerializeFormat = "\r\nProject(\"{{{0}}}\") = \"{1}\", \"{2}\", \"{{{3}}}\"\r\nEndProject";

        private Field m_solutionGuid;
        public Field SolutionGuid
        {
            get => m_solutionGuid;
            set => SetField(ref m_solutionGuid, value);
        }

        private Field m_projectName;
        public Field ProjectName
        {
            get => m_projectName;
            set => SetField(ref m_projectName, value);
        }

        private Field m_fileName;
        public Field FileName
        {
            get => m_fileName;
            set => SetField(ref m_fileName, value);
        }

        private Field m_projectGuid;
        public Field ProjectGuid
        {
            get => m_projectGuid;
            set => SetField(ref m_projectGuid, value);
        }


        public ProjectRef(Field _fileName, Field _projectName, Field _projectGuid, Field _solutionGuid = null)
        {
            FileName = _fileName;
            ProjectName = _projectName;
            ProjectGuid = _projectGuid;
            SolutionGuid = _solutionGuid;
        }

        public override void Serialize(StringBuilder _sb)
        {
            if (null != SolutionGuid)
                _sb.AppendFormat(strSerializeFormat, SolutionGuid.Value, ProjectName.Value, FileName.Value, ProjectGuid.Value);   
        }
    }
}
